#ifndef JMAINWINDOW_H
#define JMAINWINDOW_H

#include <QtGui/QMainWindow>
#include "ui_JMainWindow.h"

class JGLWidget;
class JProjectView;
class QtTreePropertyBrowser;
class JScriptConsole;

class J3DModel;
class JSTLModel;
class JKinData;

class JMainWindow : public QMainWindow
{
	Q_OBJECT

public:
	JMainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
	~JMainWindow();

protected:
	void closeEvent(QCloseEvent *event);

private slots:
	void newProject();
	void open();
	bool save();
	bool saveAs();
	void about();
	void openRecent();
	void contents();
	void shortcuts();

	void add3DModel();
	void addKinematics();

	void takeSnapshot();

	void insertKeyframe();
	void removeKeyframe();
	void playAnimation();
	void loopAnimation();

	void recordAnimationToMovie();
	void stopRecordingAnimation();

private:
	void readWindowSetting();
	void writeWindowSettings();

	void createActionLinks();

	bool saveModified();
	void updateRecentProjectActions();

	void loadProject(const QString &fileName);
	bool saveProject(const QString &fileName);

	void setCurrentProject(const QString &fileName);
	QString shortFilename(const QString &fullFileName);
	QString strippedName(const QString &fullFileName);

	const enum { MaxRecentProjects = 5 };
	QAction *mRecentProjectActs[MaxRecentProjects];

	JGLWidget* m_pGLWidget;
	//JProjectWidget* m_pProjectWidget;
	JProjectView* m_pProjectView;
	QtTreePropertyBrowser* m_pPropertyBrowser;
	JScriptConsole* m_pConsole;

	QString m_currentProjectName;

	int m_nMovieWidth;
	int m_nMovieHeight;
	int m_nFrameRate;

	QHash<int,J3DModel*> m_pModelList;
	J3DModel * m_pModel;
	//QList<J3DModel*> m_pModelList;
	//JSTLModel *m_pModel;

	bool m_bPPToggle;
	int m_nModelIndex;

	Ui::JMainWindowClass ui;
};

#endif // JMAINWINDOW_H
